//
//  main.m
//  03_homework_NSString NSArray NSMutableArray
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Book.h"
#import "BookManager.h"

/*
 1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
 2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
 3.实现图书管理系统(BookManager类)：
 使用数组管理所有书籍(Book类)。
 BookManager类属性数组可以添加、删除。
 可以从数组根据书名查找书籍，并修改书籍的价格。
 展示所有书籍清单（书名）
 */

int main(int argc, const char * argv[]) {
    
    // 1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
    NSString *str = @"20|https://www.baidu.com";
    NSArray *strArr = [str componentsSeparatedByString:@"|"];
    NSLog(@"%@", strArr);
    
    // 2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
    NSMutableArray *mutableArr = [NSMutableArray arrayWithCapacity:10];
    NSNumber *intNumber = [NSNumber numberWithInt:3];
    NSNumber *floatNumebr = [NSNumber numberWithFloat:3.3f];
    NSNumber *doubleNumber = [NSNumber numberWithDouble:3.33];
    NSNumber *boolNumber = [NSNumber numberWithBool:0];
    [mutableArr addObject:intNumber];
    [mutableArr addObject:floatNumebr];
    [mutableArr addObject:doubleNumber];
    [mutableArr addObject:boolNumber];
    NSLog(@"%@", mutableArr);
    
    // 3.实现图书管理系统(BookManager类)
    Book *b1 = [Book bookWithName:@"tangShi" price:11.1];
    Book *b2 = [Book bookWithName:@"songCi" price:22.2];
    Book *b3 = [Book bookWithName:@"yuanQu" price:33.3];
    Book *b4 = [Book bookWithName:@"guWen" price:44.4];
    Book *b5 = [Book bookWithName:@"naHan" price:55.5];
    Book *b6 = [Book bookWithName:@"pangHuang" price:66.6];
    
    BookManager *bookManager = [[BookManager alloc] init];
    [bookManager addBook:b1];
    [bookManager addBook:b2];
    [bookManager addBook:b3];
    [bookManager addBook:b4];
    [bookManager addBook:b5];
    [bookManager addBook:b6];
    
    [bookManager list];
    
    [bookManager removebook:b3];
    [bookManager list];
    
    [bookManager findBookName:@"naHan" changePrice:99.9];
    [bookManager list];
    
    [bookManager listBookName];
    
    return 0;
}
